package com.itheima.youdianda.dto;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.util.List;

/**
 * @Author Pan Rundong
 * @Date 2023-02-14 10:35
 * @Desc MP的Page类扩展
 */
@Data
public class PageDto<T> extends Page<T> {
    private long count;
    private int totalPages;

    private long pageSize;

    private long currentPages;

    private List<T> data;

    public PageDto() {

    }
    public void setValue(Page<T> pageInfo) {
        this.setCurrentPages(pageInfo.getCurrent());
        this.setData(pageInfo.getRecords());
        this.setCount(pageInfo.getTotal());
        this.setPageSize(pageInfo.getSize());
        this.totalPages = (int)(this.count/this.size)+1;
    }
}
